﻿// CSelectInject2.cpp: 实现文件
//

#include "pch.h"
#include "Injector.h"
#include "CSelectInject2.h"
#include "afxdialogex.h"
#include "CtrlCode.h"


// CSelectInject2 对话框

IMPLEMENT_DYNAMIC(CSelectInject2, CDialogEx)

CSelectInject2::CSelectInject2(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_SELECTINJECT_DIALOG2, pParent)
{

}

CSelectInject2::~CSelectInject2()
{
}

void CSelectInject2::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
    DDX_Control(pDX, IDC_COMBO_CODE_INJECTTYPE, m_ComboInjectType);
}


BEGIN_MESSAGE_MAP(CSelectInject2, CDialogEx)
    ON_BN_CLICKED(IDC_BTN_INJECTCONFIRM2, &CSelectInject2::OnBnClickedBtnInjectconfirm2)
    ON_WM_CLOSE()
END_MESSAGE_MAP()


// CSelectInject2 消息处理程序


void CSelectInject2::OnBnClickedBtnInjectconfirm2()
{
    int nType = m_ComboInjectType.GetCurSel();
    ::SendMessage(this->GetParent()->m_hWnd, WM_CODEINJECTTYPE, (WPARAM)nType, 0);
    EndDialog(0);
}

BOOL CSelectInject2::OnInitDialog()
{
    CDialogEx::OnInitDialog();

    //
    //  初始化注入方式下拉框
    //

    m_ComboInjectType.AddString(_T("远线程注入"));
    m_ComboInjectType.AddString(_T("Early Bird"));
    m_ComboInjectType.AddString(_T("Ctrl-C (Win10)"));
    m_ComboInjectType.SetCurSel(0);

    return TRUE;
}

void CSelectInject2::OnClose()
{
    ::SendMessage(this->GetParent()->m_hWnd, WM_CODEINJECTTYPE, UNKNOWN_TYPE, 0);
    CDialogEx::OnClose();
}

BOOL CSelectInject2::PreTranslateMessage(MSG* pMsg)
{
    if (pMsg->message == WM_KEYDOWN)
    {
        switch (pMsg->wParam)
        {
        case VK_ESCAPE:
            return TRUE;
        case VK_RETURN:
            return TRUE;
        default:
            break;
        }
    }

    return CDialogEx::PreTranslateMessage(pMsg);
}
